/*
** 2665.c
** 
** Made by (seakage2h)
** Login   <seakage2h@seakage2h-ubuntu>
** 
** Started on  Fri Oct  3 16:12:26 2008 seakage2h
** Last update Sun May 12 01:17:25 2002 Speed Blue
*/

/* #include "2665.h" */
#include <stdio.h>

int main()
{
     int total, seg, l, r;

     while(scanf("%d%d", &total, &seg)){
	  if (total + seg == 0) break;
	  total++;
	  while(seg){
	       scanf("%d%d", &l, &r);
	       total -= r - l + 1;
	       seg--;
	  }
	  printf("%d\n", total);
     }
     return 0;
}

	       
